package com.joyoung.datarespository;
import com.joyoung.cons.Cons;

import org.json.JSONObject;

/**
 * Created by Administrator on 2017\7\28 0028.
 */

public class HeaterBuilder {

    private JSONObject jsonObject = new JSONObject();
    private JSONObject data = new JSONObject();

    public HeaterBuilder action(String action) throws Exception {
        jsonObject.put("op_action", action);
        jsonObject.put("sessionkey", Cons.sessionkey);
        return this;
    }

    public HeaterBuilder version(String version) throws Exception{
        jsonObject.put("api_version", version);
        return this;
    }

    public HeaterBuilder devid(String devid) throws Exception{
        data.put("devid", devid);
        return this;
    }

    public HeaterBuilder sn(String sn) throws Exception{
        data.put("sn", sn);
        return this;
    }

    public HeaterBuilder type(int type) throws Exception{
        data.put("type", type);
        return this;
    }

    public HeaterBuilder open(int open) throws Exception{
        data.put("open", open);
        return this;
    }

    public HeaterBuilder hour(int hour) throws Exception{
        data.put("hour", hour);
        return this;
    }

    public HeaterBuilder minute(int minute) throws Exception{
        data.put("minute", minute);
        return this;
    }

    public HeaterBuilder temp(int temp) throws Exception{
        data.put("temp", temp);
        return this;
    }

    public HeaterBuilder cmd(String cmd) throws Exception{
        data.put("cmd", cmd);
        return this;
    }

    public String build() throws Exception {
        jsonObject.put("data", data);
        return jsonObject.toString();
    }

}
